package com.xiaoshuidi.cloud.module.contract.controller.admin.bill;


import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.contract.dal.dataobject.bill.ReadjustDO;
import com.xiaoshuidi.cloud.module.contract.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.contract.service.bill.ReadjustRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

import static com.xiaoshuidi.cloud.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 冲调记录")
@RestController
@RequestMapping(ApiConstants.NAME + "/readjust")
@Validated
public class ReadjustRecordController {

    @Autowired
    private ReadjustRecordService readjustRecordService;


    @PostMapping("/queryByOrderFeesId")
    @Operation(summary = "批量更新账单明细")
    public CommonResult<List<ReadjustDO>> queryByOrderFeesId(@Valid @RequestBody ReadjustDO updateReqVO) {

        return success(readjustRecordService.queryByOrderFeesId(updateReqVO));
    }

    @PostMapping("/batchUpdate")
    @Operation(summary = "批量更新账单明细")
    public CommonResult<Boolean> batchUpdate(@Valid @RequestBody List<ReadjustDO> updateReqVOS) {
        readjustRecordService.batchUpdate(updateReqVOS);
        return success(true);
    }
}
